package ioperation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class FindOperation implements IOPeration{
    @Override
    public void work(BookList bookList) {
        System.out.println("图书查询");
        System.out.println("输入你要查找的书名：");
        Scanner scanner=new Scanner(System.in);
        String name=scanner.nextLine();
        //getUsedSize()方法来获取书架上图书的数量
        for(int i=0;i<bookList.getUsedSize();i++){
            Book book=bookList.getBook(i);
            //根据书名来找
            if(book.getName().equals(name)){
                System.out.println(book);
                return;
            }
        }
        System.out.println("没有你想要找的书");
    }
}
